package com.example.ai.repository;

import com.example.ai.model.User;
import com.example.ai.model.WrongQuestion;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.Optional;

@Repository
public interface WrongQuestionRepository extends JpaRepository<WrongQuestion, Long> {
    Page<WrongQuestion> findByUser(User user, Pageable pageable);
    Optional<WrongQuestion> findByUserAndQuestionId(User user, Long questionId);
    boolean existsByUserAndQuestionId(User user, Long questionId);
    Page<WrongQuestion> findByUserUsername(String username, Pageable pageable);
    boolean existsByUserUsernameAndQuestionId(String username, Long questionId);
    long countByUser(User user);
    Optional<WrongQuestion> findByUserIdAndQuestionId(Long userId, Long questionId);
} 